import 'package:flutter/material.dart';
import '../pages/tabs/tab.dart';
import '../pages/ProductList.dart';
import '../pages/ProductContent.dart';
import '../pages/search.dart';
import '../pages/Login.dart';
import '../pages/Register1.dart';
import '../pages/Register2.dart';
import '../pages/Register3.dart';

//配置路由
final routes = {
  '/': (context) => Tabs(),
  '/productList': (context,{arguments}) => ProductListPage(arguments:arguments),
  '/productContent': (context,{arguments}) => ProductContentPage(arguments:arguments),
  '/search': (context) => SearchPage(),
  '/login': (context) => LoginPage(),
  '/register1': (context) => Register1Page(),
  '/register2': (context,{arguments}) => Register2Page(arguments:arguments),
  '/register3': (context,{arguments}) => Register3Page(arguments:arguments),
};
//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  print('OpenPagePath : ${settings.name} ? arguments : ${settings.arguments}');
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
